#!/bin/bash -e

if [ -n "$2" ]
then
	test_times=$1
	log_name=$2
else
	echo -e "\033[31mwarn_msg: Usage: redis_test.sh num xxx.log \033[0m";
	exit 0
fi
if [ -f $log_name ];then
	echo -e "\033[31mwarn_msg: $log_name already exists , store for $log_name.old \033[0m";
	mv $log_name $log_name.old -f
fi


echo -e "\033[36minfo_msg: sleep 20s \033[0m";
sleep 20

echo -e "\033[36minfo_msg: begin test \033[0m";
uname -a > $log_name
for ((i=0;i<$test_times;i++))
do
	echo -e "\033[36minfo_msg: do $i/$test_times \033[0m";
	taskset -c 2 redis-benchmark  -n 1000000 -r 1000000 -t set,get,lpush,lpop -d 1024  -q --csv >>$log_name
done

